package com.gitee.zhanyao.single.system.service.impl;

import com.gitee.zhanyao.single.system.entity.QSysUserAccount;
import com.gitee.zhanyao.single.system.entity.SysUser;
import com.gitee.zhanyao.single.system.entity.SysUserAccount;
import com.gitee.zhanyao.single.system.repository.SysUserAccountRepository;
import com.gitee.zhanyao.single.system.service.SysUserAccountService;
import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;

@Transactional
@Service
public class SysUserAccountServiceImpl implements SysUserAccountService {

    @Autowired
    private SysUserAccountRepository sysUserAccountRepository;

    @Autowired
    JPAQueryFactory jpaQueryFactory;

    @Override
    public SysUser findByLoginName(String loginName) {
        QSysUserAccount qSysUserAccount = QSysUserAccount.sysUserAccount;
        return jpaQueryFactory.select(qSysUserAccount.sysUser)
                .from(qSysUserAccount)
                .where(qSysUserAccount.loginName.eq(loginName))
                .fetchOne();
    }


}
